<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich" 
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <ui:composition>
        <h:head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>        
            <title>付款申请单</title>     
            <script type="text/javascript">
                javascript:window.history.forward(1);
            </script>   
            <script type="text/javascript">
                function showProj() {
                    window.open("./pubinfo/projList.jsf", "项目列表", "height=1024,width=800,toolbar=no,menubar=no,scrollbars=no");
                }

                function updateProjSelect(code, name) {
                    document.getElementById('appBill:projCode').value = code;
                    document.getElementById('appBill:projName').value = name;
                }
                function updateProj(pcode, pname)
                {
                    window.updateProjSelect(pcode, pname);
                    window.close();
                }
            </script>
            <style type="text/css">
                .inputstype{
                    width: 175px !important;
                }
                .pic{
                    margin-bottom: -4px;
                    margin-right: -2px;
                    border:none;
                    width:20px;
                    height:20px;
                }
                .col1{
                    width:60px;
                }
                .col{
                    width:200px;
                }
                .col3{
                    width:80px;
                }
                .selectStyle{
                    width: 200px;
                }
            </style>
        </h:head>
        <h:body>
            <h:form id="appBill">
                <rich:panel styleClass="content-hight">
                    <rich:messages globalOnly="true"/>
                    <h:panelGrid columns="4">
                        <h:outputLabel value="单据状态:"/>
                        <h:panelGroup>
                            <h:outputText value="已提交等待审核"  rendered="#{payApplication.exp.numberStatus eq '0'}" style="color:green"/>
                            <h:outputText value="未提交" rendered="#{payApplication.exp.numberStatus eq '1'}" style="color:red"/>
                            <h:outputText value="审核通过等待支付"  rendered="#{payApplication.exp.numberStatus eq '2'}" style="color:blue"/>
                            <h:outputText value="退回修改"  rendered="#{payApplication.exp.numberStatus eq '3'}" style="color:red"/>
                            <h:outputText value="确认支付"  rendered="#{payApplication.exp.numberStatus eq '4'}" style="color:blue"/>
                            <h:outputText value="撤单"  rendered="#{payApplication.exp.numberStatus eq '5'}" style="color:red"/>
                            <h:outputText value="支付完毕"  rendered="#{payApplication.exp.numberStatus eq '6'}" style="color:blue"/>
                        </h:panelGroup>
                        <h:outputLabel value="审核信息：" rendered="#{not empty payApplication.exp.checkInfo}" style="margin-left: 50px;"/>
                        <h:outputText value="#{payApplication.exp.checkInfo}"/>
                    </h:panelGrid>
                    <rich:toolbar  itemSeparator="grida">
                        <rich:toolbarGroup>
                            <h:commandLink action="#{payApplication.add}"
                                            disabled="#{payApplication.editStatus}" style=" margin: 1px;">
                                <h:graphicImage value="./images/create_doc.gif" styleClass="pic" title="新增"/>
                            </h:commandLink>

                            <h:commandLink  action="#{payApplication.checkSave}"
                                            actionListener="#{payApplication.clearQueryResult}"
                                            disabled="#{!payApplication.editStatus}" style=" margin: 1px;">
                                <h:graphicImage value="./images/save.gif" styleClass="pic" title="保存"/>
                            </h:commandLink>

                            <h:commandLink  action="#{payApplication.update}" style=" margin: 1px;"
                                            disabled="#{payApplication.editStatus || payApplication.exp.number eq '' || (payApplication.exp.numberStatus != '1' and payApplication.exp.numberStatus != '3')}">
                                <h:graphicImage value="./images/edit.gif" styleClass="pic" title="修改"/>
                            </h:commandLink>

                            <h:commandLink   action="#{payApplication.delete}"
                                             actionListener="#{payApplication.clearQueryResult}" style=" margin: 1px;"
                                             disabled="#{payApplication.editStatus || payApplication.exp.number eq '' || (payApplication.exp.numberStatus != '1' and payApplication.exp.numberStatus != '3')}">
                                <h:graphicImage value="./images/delete.gif" styleClass="pic" title="删除"/>
                            </h:commandLink>

                            <h:commandLink action="#{payApplication.cancel}"
                                           immediate="true"
                                           style=" margin: 1px;text-decoration: none;"
                                           disabled="#{!payApplication.editStatus}" >
                                <h:panelGroup style="white-space: nowrap;">
                                    <h:graphicImage value="./images/cancel.png" styleClass="pic"/>
                                    <h:outputLabel value="取消" />
                                </h:panelGroup>
                            </h:commandLink>

                            <h:commandLink  action="#{payApplication.submitApp}"
                                            actionListener="#{payApplication.clearQueryResult}" 
                                            style=" margin: 1px;text-decoration: none;"
                                            disabled="#{payApplication.addOrUpdate || payApplication.exp.number eq '' || !payApplication.saveOrNot || payApplication.exp.numberStatus != '1'}">
                                <h:panelGroup style="white-space: nowrap;">
                                    <h:graphicImage value="./images/submit.png" styleClass="pic" />
                                    <h:outputLabel value="提交" />
                                </h:panelGroup>
                            </h:commandLink>

                            <h:commandLink  action="#{payApplication.rescindApp}"
                                            actionListener="#{payApplication.clearQueryResult}"
                                            disabled="#{payApplication.editStatus || payApplication.exp.numberStatus != '0'}"
                                            style=" margin: 1px;text-decoration: none;">
                                <h:panelGroup style="white-space: nowrap;">
                                    <h:graphicImage value="./images/repeat.png" styleClass="pic"/>
                                    <h:outputLabel value="撤单" />
                                </h:panelGroup>
                            </h:commandLink>

                            <h:commandLink  action="#{payApplication.getFirst}"
                                            disabled="#{payApplication.editStatus}" style=" margin: 1px;">
                                <h:graphicImage value="./images/btn_page_first.gif" styleClass="pic" title="首张"/>
                            </h:commandLink>

                            <h:commandLink  action="#{payApplication.previous}"
                                            disabled="#{payApplication.editStatus}" style=" margin: 1px;">
                                <h:graphicImage value="./images/btn_page_up.gif" styleClass="pic" title="上张"/>
                            </h:commandLink>

                            <h:commandLink   action="#{payApplication.next}"
                                             disabled="#{payApplication.editStatus}" style=" margin: 1px;">
                                <h:graphicImage value="./images/btn_page_down.gif" styleClass="pic" title="下张"/>
                            </h:commandLink>

                            <h:commandLink  action="#{payApplication.getLast}"
                                            disabled="#{payApplication.editStatus}" style=" margin: 1px;">
                                <h:graphicImage value="./images/btn_page_end.gif" styleClass="pic" title="末张"/>
                            </h:commandLink>

                            <a4j:commandLink  render="loanPdf" execute="@form"
                                              oncomplete="#{rich:component('voucherPanel')}.show()"
                                              disabled="#{payApplication.editStatus or empty payApplication.exp.number}"
                                              style=" margin: 1px;">
                                <h:graphicImage value="./images/print.gif" styleClass="pic" title="打印"/>
                            </a4j:commandLink>

                        </rich:toolbarGroup>
                    </rich:toolbar>
                    <p style="text-align:center;font-family:黑体;font-weight:bold;font-size: 20px !important;" >付 款 申 请 单</p>
                    <hr style="border:1px dashed;"/>
                    <h:panelGroup  id="edit">
                        <h:panelGrid columns="6" width="100%" border="0" id="appBillinput" 
                                     style="text-align:left;" columnClasses="col1,col2,clo2,col1,col2,clo2">
                            <h:outputLabel value="单据编号:" />
                            <h:inputText  id="number"  disabled="true" size="28"
                                          value="#{payApplication.exp.number}"
                                          required="true" requiredMessage="不能为空"/>
                            <rich:message for="number"/>

                            <h:outputLabel value="单据日期:" />
                            <rich:calendar id="billDate"
                                           disabled="#{!payApplication.editStatus}"
                                           value="#{payApplication.exp.numDate}"
                                           locale="zh_CN"
                                           popup="true"
                                           datePattern="yyyy-MM-dd"
                                           showApplyButton="false"
                                           inputClass="inputstype"
                                           required="true" requiredMessage="不能为空">
                            </rich:calendar>
                            <rich:message for="billDate"/>

                            <h:outputLabel value="项目编码:"/>
                            <h:inputText id="projCode" size="28"
                                         disabled="#{!payApplication.editStatus}"
                                         value="#{payApplication.exp.customProjCode}"/>
                            <rich:message for="projCode"/>

                            <h:outputLabel value="预算项目:"/>
                            <h:inputText  id="projName" size="28" disabled="#{!payApplication.editStatus}"
                                          value="#{payApplication.exp.project.finName}"
                                          onclick="#{rich:component('projPanel')}.show();"/>
                            <rich:message for="projName"/>

                            <h:outputLabel value="用途:"/>
                            <h:inputText  id="affair" size="28" disabled="#{!payApplication.editStatus}"
                                          value="#{payApplication.exp.affair}"
                                          required="true" requiredMessage="不能为空"
                                          validatorMessage="请勿超过30个字">
                                <f:validateLength maximum="30"/>
                            </h:inputText>
                            <rich:message for="affair"/>

                            <h:outputLabel value="付款部门:" />
                            <h:inputText id="paydept" disabled="#{!payApplication.editStatus}" value="#{payApplication.exp.payDept.name}"
                                         onclick="#{rich:component('deptPanel')}.show();" size="28"/>
                            <rich:message for="paydept"/>

                            <h:outputLabel value="申请人:" />
                            <rich:select id="feePerson" value="#{payApplication.exp.feePer.cpsn_number}"  
                                         enableManualInput="true"
                                         styleClass="selectStyle"
                                         disabled="#{!payApplication.editStatus}"
                                         required="#{payApplication.editStatus}" requiredMessage="不能为空">
                                <f:selectItem itemValue="" itemLabel="-请选择-"/>
                                <f:selectItems value="#{payApplication.perli}" />
                            </rich:select>
                            <rich:message for="feePerson"/>

                            <h:outputLabel value="收款单位:"  />
                            <h:inputText  id="receriver" size="28" disabled="#{!payApplication.editStatus}"
                                          value="#{payApplication.partner.simplename}" 
                                          required="true" requiredMessage="不能为空"
                                          validatorMessage="请勿超过20个字">
                                <f:validateLength maximum="20"/>
                            </h:inputText>
                            <rich:message for="receriver"/>

                            <h:outputLabel value="开户行:"  />
                            <h:inputText  id="bank"  size="28" disabled="#{!payApplication.editStatus}"
                                          value="#{payApplication.partner.bank}" 
                                          required="true" requiredMessage="不能为空"
                                          validatorMessage="请勿超过50个字">
                                <f:validateLength maximum="50"/>
                            </h:inputText>
                            <rich:message for="bank"/>

                            <h:outputLabel value="账号:"  />
                            <h:inputText  id="account" size="28" disabled="#{!payApplication.editStatus}"
                                          value="#{payApplication.partner.bankAccount}" 
                                          required="true" requiredMessage="不能为空"
                                          validatorMessage="请勿超过30个字符">
                                <f:validateLength maximum="30"/>
                            </h:inputText>
                            <rich:message for="account"/>

                            <h:outputLabel value="币种:"  />
                            <h:selectOneMenu  id="currency"  value="#{payApplication.exp.currency.code}"
                                              disabled="#{!payApplication.editStatus}" style="width:198px;"
                                              required="true" requiredMessage="不能为空">
                                <f:selectItem itemValue="" itemLabel="-请选择-"/>
                                <f:selectItems value="#{payApplication.currencys}" />
                            </h:selectOneMenu>
                            <rich:message for="currency"/>

                            <h:outputLabel value="金额:"  />
                            <h:inputText id="total" size="28" disabled="#{!payApplication.editStatus}"
                                         value="#{payApplication.exp.total}"
                                         required="true" requiredMessage="不能为空"
                                         converterMessage="请输入正确的数字。">
                                <f:validateDoubleRange/>
                                <f:convertNumber type="double" pattern="###,##0.00"/>
                            </h:inputText>
                            <rich:message for="total" />

                            <h:outputText value="支付方式:"/>
                            <h:selectOneMenu  id="payway" value="#{payApplication.exp.payStyle.code}"
                                              valueChangeListener="#{payApplication.payStyleChange}"
                                              disabled="#{!payApplication.editStatus}"
                                              style="width:198px;"
                                              required="true" requiredMessage="不能为空">
                                <f:selectItem itemValue="" itemLabel="-请选择-"/>
                                <f:selectItems value="#{payApplication.payStylelist}"/>
                            </h:selectOneMenu>
                            <rich:message for="payway"/>

                            <h:outputLabel value="备注:"  />
                            <h:selectOneMenu  id="memo"  value="#{payApplication.exp.memo}"
                                              disabled="#{!payApplication.editStatus}"
                                              style="width:198px;"
                                              required="true" requiredMessage="不能为空">
                                <f:selectItem itemValue="" itemLabel="-请选择-"/>
                                <f:selectItems value="#{payApplication.memo}" />
                            </h:selectOneMenu>
                            <rich:message for="memo"/>

                            <h:outputLabel value="附件张数：" />
                            <h:inputText  id="affixAmount"   size="28"
                                          disabled="#{!payApplication.editStatus}"
                                          value="#{payApplication.exp.affixAmount}" 
                                          required="true" requiredMessage="不能为空" />
                            <rich:message for="affixAmount"/>

                        </h:panelGrid>
                        <hr style="border:1px dashed;"/>
                        <h:panelGrid columns="6" width="100%" border="0" id="end" columnClasses="col1,col,clo2,col3,col,clo2">
                            <h:outputLabel value="部门名称:" />
                            <h:outputText  id="department"   value="#{payApplication.exp.dept.name}"  />
                            <rich:message for="department"/>

                            <h:outputLabel value="制 单 人：" />
                            <h:outputText  id="person"    value="#{payApplication.exp.user.cpsn_name}"  />
                            <rich:message for="person"/>
                        </h:panelGrid>
                    </h:panelGroup>
                </rich:panel>
            </h:form>
            <rich:popupPanel id="projPanel" autosized="true">
                <f:facet name="header">项目信息</f:facet>
                <f:facet name="controls">
                    <h:outputLink value="#" onclick="#{rich:component('projPanel')}.hide()">关闭</h:outputLink>
                </f:facet>
                <h:form id="projList">
                    <rich:dataTable id="editTable" value="#{payApplication.finProjModel}" rows="10"  var="pro"
                                    onrowmouseover="this.style.backgroundColor='#F1F1F1'"
                                    onrowmouseout="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                                    rowClasses="list-row-odd,list-row-even">
                        <rich:column>
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="预算项目编码"/>
                                </h:panelGroup>
                            </f:facet>
                            <a4j:commandLink id="Projlinks" action="#{payApplication.projSelected}"
                                             onclick="#{rich:component('projPanel')}.hide();"
                                             render="projName" >
                                <h:outputText value="#{pro.finCode}"/>
                            </a4j:commandLink>
                        </rich:column>

                        <rich:column>
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="预算项目名称"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{pro.finName}"/>
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="备注"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{pro.memo}"/>
                        </rich:column>

                        <f:facet name="footer">
                            <rich:dataScroller id="ds"></rich:dataScroller>
                        </f:facet>
                    </rich:dataTable>
                </h:form>
            </rich:popupPanel>
            <rich:popupPanel id="voucherPanel" width="950" height="600">
                <f:facet name="header">
                    <h:panelGroup>
                        <h:outputText value="打印"></h:outputText>
                    </h:panelGroup>
                </f:facet>

                <f:facet name="controls">
                    <h:outputLink value="#" onclick="#{rich:component('voucherPanel')}.hide()">关闭</h:outputLink>
                </f:facet>
                <a4j:mediaOutput element="object" cacheable="false" id="loanPdf"
                                 uriAttribute="data"
                                 standby="Loading Pdf..." mimeType="application/pdf"
                                 type="application/pdf" style="width: 900px;height: 550px"
                                 createContent="#{payApplication.process}" />
            </rich:popupPanel>

            <rich:popupPanel id="deptPanel" autosized="true">
                <f:facet name="header">
                    <h:panelGroup>
                        <h:outputText value="费用承担部门"></h:outputText>
                    </h:panelGroup>
                </f:facet>
                <f:facet name="controls">
                    <h:outputLink value="#" onclick="#{rich:component('deptPanel')}.hide();">关闭</h:outputLink>
                </f:facet>
                <h:form>
                    <rich:panel>
                        <h:panelGrid columns="2"  border="0" id="mainform">
                            <rich:tree value="#{departmentBean.rootNode}" var="idept"
                                       selectionType="ajax" toggleType="client"
                                       selectionChangeListener="#{payApplication.selected}"
                                       style="width:300px" render="paydept,feePerson">
                                <rich:treeNode>
                                    <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                                    <rich:componentControl target="deptPanel" operation="hide" event="click"/>
                                </rich:treeNode>
                            </rich:tree>
                        </h:panelGrid>
                    </rich:panel>
                </h:form>

                <f:facet name="footer">
                    footer!
                </f:facet>

            </rich:popupPanel>

            <rich:popupPanel id="projQueryPanel" autosized="true">
                <f:facet name="header">项目信息</f:facet>
                <f:facet name="controls">
                    <h:outputLink value="#" onclick="#{rich:component('projQueryPanel')}.hide()">关闭</h:outputLink>
                </f:facet>
                <h:form id="projQueryList">
                    <rich:dataTable id="editTableQuery" value="#{payApplication.finProjModel}" rows="10"  var="pro"
                                    onrowmouseover="this.style.backgroundColor='#F1F1F1'"
                                    onrowmouseout="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                                    rowClasses="list-row-odd,list-row-even">
                        <rich:column>
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="预算项目编码"/>
                                </h:panelGroup>
                            </f:facet>
                            <a4j:commandLink id="ProjQuerylinks" action="#{payApplication.selectProjForQuery}"
                                             onclick="#{rich:component('projQueryPanel')}.hide();"
                                             render="proName" >
                                <h:outputText value="#{pro.finCode}"/>
                            </a4j:commandLink>
                        </rich:column>

                        <rich:column>
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="预算项目名称"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{pro.finName}"/>
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="备注"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{pro.memo}"/>
                        </rich:column>

                        <f:facet name="footer">
                            <rich:dataScroller id="ds"></rich:dataScroller>
                        </f:facet>
                    </rich:dataTable>
                </h:form>
            </rich:popupPanel>
        </h:body>
    </ui:composition>
</html>
